package com.clg.javafx.views

import com.clg.javafx.controllers.DbController
import com.clg.javafx.datas.Tree
import javafx.scene.Parent
import javafx.scene.control.TreeItem
import tornadofx.*

/**
 * Created by 林光 on 2017/4/17.
 */
class LeftView: View("Left View"){
    val controller:DbController by inject()
    lateinit var parent:MainView

    override val root = treeview<Tree>  {
        cellFormat { text = it.name }
        root = TreeItem(Tree(messages["TABLE"]))
    }


    init {
        with(root) {
            val tables = controller.loadAllTable()
            for(table in tables){
                root.children.add(TreeItem(Tree(table.tableName)))
            }

            root.children.forEach({
                setOnMouseClicked {
                    openInternalWindow(OpenView::class)
                }

            })
        }

    }
}

class OpenView() :Fragment(){
    override val root = hbox {
        button("ddd")
    }
}